﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace KPIS.GERP.GBMS.APP_UI.Form
{
    public partial class _SampleRadGrid : System.Web.UI.Page
    {
        private string[] q = new[] {"ไตรมาส 1", "ไตรมาส 2", "ไตรมาส 3", "ไตรมาส 41"};
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        private void LoadGridQuarter()
        {
            Dictionary<string, double> QuarterKPI = new Dictionary<string, double>
                                                      {
                                                              {"ไตรมาส 1", 0},
                                                              {"ไตรมาส 2", 0},
                                                              {"ไตรมาส 3", 0},
                                                              {"ไตรมาส 4", 0},
                                                      };

            RadGrid1.DataSource = QuarterKPI;
            RadGrid1.DataBind();
        }

        private void LoadGridYear()
        {
            Dictionary<string, double> YearKPI = new Dictionary<string, double>
                                                      {
                                                              {"รายปี", 0}
                                                      };

            RadGrid1.DataSource = YearKPI;
            RadGrid1.DataBind();
        }

        protected void RadComboBox1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (RadComboBox1.SelectedIndex == 0)
                LoadGridQuarter();
            else
                LoadGridYear();
        }

        protected void RadGrid1_PreRender(object sender, EventArgs e)
        {
            foreach (GridDataItem i in RadGrid1.Items)
                i.Edit = true;
            RadGrid1.Rebind();
        }

        protected void RadButton1_Click(object sender, EventArgs e)
        {
            string test = "";
            foreach (GridDataItem item in RadGrid1.Items)
            {
                test += (item["KPI_Value2"].FindControl("tex") as RadNumericTextBox)
                    .Value.ToString();
            }
            test = test;
        }
    }
}
